home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / c.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-30  |  1.7 KB  |  72 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for C functions. Scan handlers are plain
  17.   functions (LoadSeg'ed by GED): no standard C startup code, no library calls.
  18.   
  19.   DICE-C:
  20.   
  21.   dcc c.c -// -l0 -md -mRR -o ram:c
  22.  
  23.   ------------------------------------------------------------------------------
  24. */
  25.  
  26. #include <exec/types.h>
  27.  
  28. ULONG
  29. ScanHandlerC(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  30. {
  31.     const char *version = "$VER: C 1.0 (" __COMMODORE_DATE__ ")";
  32.  
  33.     if (len) {
  34.  
  35.         UBYTE *from = *text;
  36.  
  37.         if (*from != 32) {
  38.  
  39.             UBYTE *last;
  40.  
  41.             for (last = from + len - 1; len && (*last == 32); --len)
  42.                 --last;
  43.  
  44.             if ((*last == ')') && (((*from >= 'A') && (*from <= 'Z')) || ((*from >= 'a') && (*from <= 'z')))) {
  45.  
  46.                 UBYTE *nextChar;
  47.                 UWORD  words;
  48.  
  49.                 for (words = 0, nextChar = from; nextChar < last; ++nextChar) {
  50.  
  51.                     if (*nextChar == '(') {
  52.  
  53.                         *text = from;
  54.  
  55.                         return((ULONG)(nextChar - from));
  56.                     }
  57.                     else if (*nextChar < '0') {
  58.  
  59.                         from = nextChar + 1;
  60.  
  61.                         if (++words > 3)
  62.                             break;
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68.  
  69.     return(FALSE);
  70. }
  71.  
  72.